//@符号表示 src路径
//导入aixos对象
import request from "@/utils/request"

//登录,data对象,传后端的数据
const findHotProducts = () => {
    //调用axios
    return request({
        // /api/代理成 http://localhost:8080/ 进行访问
        url: "/api/product/hotProducts",
        method: "get",
    })
}
//查询新品上市
const findNewProducts = () => {
    return request({
        url: "/api/product/newProducts",
        method: "get",
    })
}
//查询鞋的种类
const findCategories = () => {
    return request({
        url: "/api/product/categories",
        method: "get",
    })
}
//按id查询商品详情
const getProductDetail = (productId) => {
    return request({
        url: "/api/product/detail/" + productId,
        method: "get",
    })
}
//查询搜索商品
const searchProducts = (params) => {
    return request({
        url: "/api/product/search",
        method: "get",
        params
    })
}
//查询所有品牌
const findAllProductsBrands=()=>{
    return request({
        url: "/api/product/brands",
        method: "get",
    })
}
//查询所有商品
const findAllProducts=()=>{
    return request({
        url: "/api/product/getAllProducts",
        method: "get",
    })
}
//update
const updateProduct = (product) => {
    return request({
        url: "/api/product/updateShoesInfo",
        method: "post",
          headers: { "Content-Type": "application/json;charset=utf-8" },
        data: product
    })
}
//delete
const deleteProduct = (sid) => {
    return request({
        url: `/api/product/delete?sid=${sid}`,
        method: "delete",
    })
}
//add
const addProduct = (product) => {
    return request({
        url: "/api/product/add",
        method: "post",
        headers: { "Content-Type": "application/json;charset=utf-8" },
        data: product

    })
}
//updateShoesDelete
const updateShoesDelete = (sid) => {
    return request({
        url: `/api/product/updateShoeSdelete?sid=${sid}`,
        method: "post",
    })
}

// 上传图片
const uploadFileReq = (formData) => {
    return request({
        url: "/api/file/upload",
        method: "post",
        headers: { "Content-Type": "multipart/form-data" },
        data: formData
    })
}


export { findHotProducts,findNewProducts,findCategories,getProductDetail,searchProducts,findAllProductsBrands,findAllProducts,updateProduct,deleteProduct,addProduct,updateShoesDelete,uploadFileReq }